package emulator.hardware.nmos6502.commands;

import emulator.EmulatorException;
import emulator.hardware.nmos6502.Command;
import emulator.hardware.nmos6502.CommandSet;
import emulator.hardware.nmos6502.Cpu6502;
import emulator.hardware.nmos6502.Operand;
import emulator.hardware.nmos6502.operands.Absolute;
import emulator.hardware.nmos6502.operands.AbsoluteX;
import emulator.hardware.nmos6502.operands.AbsoluteY;
import emulator.hardware.nmos6502.operands.IndirectX;
import emulator.hardware.nmos6502.operands.IndirectY;
import emulator.hardware.nmos6502.operands.ZeroPage;
import emulator.hardware.nmos6502.operands.ZeroPageX;

/** STA (STore Accumulator)
 *  
 *  Affects Flags: none
 *  
 *  MODE           SYNTAX       HEX LEN TIM
 *  Zero Page     STA $44       $85  2   3
 *  Zero Page,X   STA $44,X     $95  2   4
 *  Absolute      STA $4400     $8D  3   4
 *  Absolute,X    STA $4400,X   $9D  3   5
 *  Absolute,Y    STA $4400,Y   $99  3   5
 *  Indirect,X    STA ($44,X)   $81  2   6
 *  Indirect,Y    STA ($44),Y   $91  2   6
 */
public class STA implements Command {

	@Override
	public void execute(Cpu6502 cpu, Operand operand) throws EmulatorException {
		operand.setByte(cpu.getAccu());
	}

	@Override
	public String getName() {
		return "STA";
	}

	@Override
	public void register(CommandSet cset) {
		 cset.defineCommand(0x85, this, new ZeroPage());
		 cset.defineCommand(0x95, this, new ZeroPageX());
		 cset.defineCommand(0x8D, this, new Absolute());
		 cset.defineCommand(0x9D, this, new AbsoluteX());
		 cset.defineCommand(0x99, this, new AbsoluteY(false), 3);
		 cset.defineCommand(0x81, this, new IndirectX());
		 cset.defineCommand(0x91, this, new IndirectY());
	}

}
